
import { _decorator, Component, Node, EventTouch } from 'cc';
import { GuidelineComponent } from './guideline-component';
const { ccclass, property } = _decorator;


@ccclass('MainScene')
export class MainScene extends Component {

    @property(GuidelineComponent)
    guideline: GuidelineComponent = null;

    @property([Node])
    targets: Node[] = [];

    start() {
        setTimeout(() => {
            this.showGuildline(this.targets[0]);
        }, 1000);
    }

    private showGuildline(target: Node) {
        this.guideline.show(target);
    }

    private onTouchTarget(event: EventTouch) {
        this.guideline.hide();

        const index = this.targets.indexOf(event.currentTarget as Node);
        if (index != -1) {
            const next = this.targets[index + 1];
            if (next) {
                this.showGuildline(next);
            }
        }
    }
}